<?php /* Smarty version 2.6.18, created on 2008-06-12 23:41:39
         compiled from admin/Websetup_user.html */ ?>
<?php require_once(SMARTY_CORE_DIR . 'core.load_plugins.php');
smarty_core_load_plugins(array('plugins' => array(array('function', 'get_app_inf', 'admin/Websetup_user.html', 4, false),array('function', 'webcontrol', 'admin/Websetup_user.html', 231, false),)), $this); ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">  
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">  
<head>  
<title><?php echo $this->_plugins['function']['get_app_inf'][0][0]->_pi_func_get_app_inf(array('key' => 'siteName'), $this);?>
 - <?php echo $this->_tpl_vars['title']; ?>
</title>
<meta http-equiv="Content-type" content="text/html; charset=utf-8" />  
<!-- add your meta tags here -->  
  
<link href="css/my_layout.css" rel="stylesheet" type="text/css" />
<link href="css/screen/user.css" rel="stylesheet" type="text/css" />
<!--[if lte IE 7]>  
<link href="css/my_patches/patch_my_layout.css" rel="stylesheet" type="text/css" />  
<![endif]-->  
<script type="text/javascript" src="script/jquery.js"><!-- jQuery 1.2.1 --></script>
<script type="text/javascript" src="script/jquery.form.js"><!-- 表单Ajax插件 --></script>
<script type="text/javascript" src="script/yav.js"><!-- 表单验证插件 --></script>
<script type="text/javascript" src="script/jquery.yav.pack.js"><!-- 表单验证插件 --></script>
<script type="text/javascript" src="script/jquery.confirm.js"><!-- 对话框插件 --></script>

<script type="text/javascript">
// DOM载入时执行
$(function() {

	// 绑定用户列表鼠标悬停事件
	$("#userList tr").hover(function() {
		$(this).addClass("OMover");
	},function(){
		$(this).removeClass("OMover");
	});
	
	// 改变用户状态的颜色和文字，0为绿色'正常'，1为红色'禁用'
	$(".blocked").each(function() {
	
		if( $(this).text() == 0 ) {
			$(this).addClass("green").text('正常');
		}else{
			$(this).addClass("red").text('禁用');
		}
		
	});
	
	// 改变登录时间为0的文字
	$(".login_at").each(function() {
	
		if( $(this).text() == 0 ) {
			$(this).addClass("grey").text('未登录过');
		}
	
	});
	
	// 给当前类加上selected
	$("#select_ug_id").val(<?php echo $this->_tpl_vars['ug_id']; ?>
);
	
	// 绑定下拉列表的动作
	$("#select_ug_id").change(function(){
		document.location = '?controller=admin_user&action=userlist&ug_id=' + $(this).val();
	});


	// 全选/全部不选
	$("#selectAll").click(function() {
		$("input:checkbox").attr("checked","checked");
	});
	$("#unselectAll").click(function() {
		$("input:checkbox").removeAttr("checked");
	});
	
	
	//绑定修改表单中下拉列表框的click事件，当点击时从服务器ajax方式获得不包含当前节点树的option列表
	$("#u_select_user_group").click(function() {
	
		//删除点击前添加的option项
		$("#option_ug_id").remove();
		
		//在下拉框为空的情况下才通过ajax获取数据
		if(!$(this).html()) {
			$.get("websetup.php", {
				controller : 'admin_usergroup',
				action     : 'ajaxtree',
				id		   : -1
			},function(response){
						// alert(response);
				list = eval('(' + response + ')');
				for (i = 0, max = list.length; i < max; i++) {
					$("#u_select_user_group").append("<option value='" + list[i].user_group_id + "'>" + 
												list[i].levelstr + list[i].group_name + "</option>");
				}
			});
		}
		
	}); // end 绑定修改表单中下拉列表框的click事件
	
	
	// 验证用户修改表单
	$("#formUserUpdate").yav();
	$("#formUserCreate").yav();
	
	// 添加新用户
	$("#linkUserCreate").click(function() {
		ug_id = "<?php echo $this->_tpl_vars['ug_id']; ?>
";
		if(ug_id){
			// alert(ug_id);
			
			// 删除已存在的修改表单
			_removeModifyForm();
			
			// 添加一个空tr，然后将表单移动到空的tr当中去
			$("#tr_0").after("<tr class='userModifyform'><td colspan='8'>" + "</td></tr>");
			$("#formUserCreate").appendTo(".userModifyform td");
			
			// 预填写表单
			$("#span_user_group_id").text( " 『 " + $("#select_ug_id option:selected").attr("ugname") + " 』 " );
			$("#c_user_group_id").val( $("#select_ug_id option:selected").val() );
			
		}else{
			alert('请先选择右侧的用户组后再添加用户');
		}
		return false;
	});
	
	//禁用开关及禁用项的ajax提交
	$(".block_switch").click(function() {
			
			member_id = $(this).attr("member_id");
	
			if($(this).text()=="禁用"){
				$(this).text("启用");
				$.post("websetup.php?controller=admin_user&action=ajaxblockupdate", 
				{
					member_id   : member_id,
					is_blocked  : 1
				},function(response){
					if(response){
						$("#tr_" + member_id + " .blocked").removeClass("green").addClass("red").text('禁用');
					}
				});
			}else{
				$(this).text("禁用");
				$.post("websetup.php?controller=admin_user&action=ajaxblockupdate", 
				{
					member_id   : member_id,
					is_blocked  : 0
				},function(response){
					if(response){
						$("#tr_" + member_id + " .blocked").removeClass("red").addClass("green").text('正常');
					}
				});
				
			}
			return false;
			
	});
		
	// ajax删除一条用户记录(已经用confirm绑定)
	$(".linkUserRemove").click(function() {

		$.get("websetup.php", {
			controller : 'admin_user',
			action     : 'ajaxuserRemove',
			member_id  : $(this).attr("member_id")
		},function(data){
		 	if(data){
		 		location.reload();
		 	}else{
		 		alert('未知错误，未能删除！');
		 	}
		});
		
	}); //end ajax删除一条用户记录
	
	
	// 用confirm捕获删除链接的click事件
	$('.linkUserRemove').confirm({
		msg:'<img src="images/notice.gif" /> ',
		stopAfter:'ok',
		eventType:'click',
		timeout:3000,
		buttons: {
			ok:'确认',
			cancel:'取消',
			separator:' | '
		}
	});
	


});

// 修改用户表单显示及预填写
function userUpdate(member_id, username, email, user_group_id, user_group_name) {

	// 删除已存在的修改表单
	_removeModifyForm();
	
	// 点击修改链接时在当前tr后面插入修改表单
	$("#tr_" + member_id).after( "<tr class='userModifyform'><td colspan='8'>" + "</td></tr>" );
	$("#formUserUpdate").appendTo(".userModifyform td");
	
	// 预填写表单
	$("#u_member_id").val(member_id);
	$("#u_username").val(username);
	$("#u_email").val(email);
	$("#u_select_user_group").append("<option id=\"option_ug_id\" value=\"" + user_group_id + "\">" + user_group_name + "</option>");

}

// 删除已存在的修改表单
function _removeModifyForm() {
	$("#formUserCreate").appendTo("#divUserCRUD");
	$("#formUserUpdate").appendTo("#divUserCRUD");
	$("#select_user_group").empty();
	$("#userList .userModifyform").remove();
}

</script>

</head>  
<body> 
  <div id="page_margins">

    <div id="border-top">
      <div id="edge-tl"></div>
      <div id="edge-tr"></div>
    </div>
    <div id="page">
      <?php $_smarty_tpl_vars = $this->_tpl_vars;
$this->_smarty_include(array('smarty_include_tpl_file' => "admin/Websetup_header.html", 'smarty_include_vars' => array()));
$this->_tpl_vars = $_smarty_tpl_vars;
unset($_smarty_tpl_vars);
 ?>
      <?php $_smarty_tpl_vars = $this->_tpl_vars;
$this->_smarty_include(array('smarty_include_tpl_file' => "admin/Websetup_nav.html", 'smarty_include_vars' => array()));
$this->_tpl_vars = $_smarty_tpl_vars;
unset($_smarty_tpl_vars);
 ?>

      <div id="main">
        <div id="col1">
          <div id="col1_content" class="clearfix">
				<?php echo $this->_plugins['function']['webcontrol'][0][0]->_pi_func_webcontrol(array('type' => 'menu','name' => 'myMenu'), $this);?>

          </div>
        </div>
        <div id="col3">
          <div id="col3_content" class="clearfix">
            
				<?php $_smarty_tpl_vars = $this->_tpl_vars;
$this->_smarty_include(array('smarty_include_tpl_file' => "admin/Websetup_user_list.html", 'smarty_include_vars' => array()));
$this->_tpl_vars = $_smarty_tpl_vars;
unset($_smarty_tpl_vars);
 ?>
            
          </div>
          <!-- IE Column Clearing -->
          <div id="ie_clearing"> &#160; </div>
        </div>
      </div>
      <!-- begin: #footer -->
      <?php $_smarty_tpl_vars = $this->_tpl_vars;
$this->_smarty_include(array('smarty_include_tpl_file' => "admin/Websetup_footer.html", 'smarty_include_vars' => array()));
$this->_tpl_vars = $_smarty_tpl_vars;
unset($_smarty_tpl_vars);
 ?>
    </div>
    <div id="border-bottom">
      <div id="edge-bl"></div>
      <div id="edge-br"></div>
    </div>
  </div>
</body>
</html>